Crate testcontainers_modules
source ·Expand description
§testcontainers-modules
Community maintained modules for testcontainers
Provides modules to use for testing components in accordance with testcontainers-rs. Every module is treated as a feature inside this crate.
§Usage
- Depend on testcontainers-modules with necessary features (e.g
postgres
,minio
and etc)- Enable
blocking
feature if you want to use modules within synchronous tests (feature-gate forSyncRunner
)
- Enable
- Then start using the modules inside your tests with either
AsyncRunner
orSyncRunner
Simple example of using postgres
module with SyncRunner
(blocking
and posrges
features enabled):
ⓘ
use testcontainers_modules::{postgres, testcontainers::runners::SyncRunner};
#[test]
fn test_with_postgres() {
let container = postgres::Postgres::default().start();
let host_ip = container.get_host();
let host_port = container.get_host_port_ipv4(5432);
}
Note: you don’t need to explicitly depend on testcontainers
as it’s re-exported dependency
of testcontainers-modules
with aligned version between these crates.
For example:
use testcontainers_modules::testcontainers::RunnableImage;
You can also see examples for more details.
§How to override module defaults (version, tag, ENV-variables)
Just use RunnableImage:
ⓘ
use testcontainers_modules::{
redis::Redis,
testcontainers::RunnableImage
};
/// Create a Redis module with `6.2-alpine` tag and custom password
fn create_redis() -> RunnableImage<Redis> {
RunnableImage::from(Redis::default())
.with_tag("6.2-alpine")
.with_env_var(("REDIS_PASSWORD", "my_secret_password"))
}
§License
- MIT license (LICENSE or http://opensource.org/licenses/MIT)
Please have a look at the documentation of the separate modules for examples on how to use the module.
Re-exports§
pub use testcontainers;
Modules§
- cncf_distribution
cncf_distribution
- cockroach_db
cockroach_db
- consul
consul
- dynamodb_local
dynamodb
- elastic_search
elastic_search
- elasticmq
elasticmq
- google_cloud_sdk_emulators
google_cloud_sdk_emulators
- k3s
k3s
- kafka
kafka
- kwok
kwok
- localstack
localstack
- mariadb
mariadb
- minio
minio
- mongo
mongo
- mosquitto
mosquitto
- mssql_server
mssql_server
- mysql
mysql
- nats
nats
- neo4j
neo4j
- orientdb
orientdb
- parity_parity
parity
- postgres
postgres
- rabbitmq
rabbitmq
- redis
redis
- solr
solr
- surrealdb
surrealdb
- trufflesuite_ganachecli
trufflesuite_ganachecli
- victoria_metrics
victoria_metrics
- zookeeper
zookeeper